﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;
using CommomFunctions;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Animation;

namespace Listas
{
    public class Images : CommomFunctions.Imagens
    {
        /// <summary>
        /// Creates and adds to grid all the images that will be used to indicates the List emptyness (BeginNull, EndNull and Null)
        /// and the List begin and end (Begin and End)
        /// </summary>
        /// <param name="gd"></param>
        internal void createControlImages(Grid gd)
        {
            loadSources();

            setAlignments(WorkingImage.Begin, Stretch.Uniform, VerticalAlignment.Bottom, HorizontalAlignment.Center);
            setCollumnsAndLines(WorkingImage.Begin, gd, 0, 9, 2, 2);

            setAlignments(WorkingImage.End, Stretch.Uniform, VerticalAlignment.Bottom, HorizontalAlignment.Center);
            setCollumnsAndLines(WorkingImage.End, gd, 0, 9, 1, 1);

            setAlignments(WorkingImage.BeginNull, Stretch.Uniform, VerticalAlignment.Bottom, HorizontalAlignment.Center);
            setCollumnsAndLines(WorkingImage.BeginNull, gd, 0, 9, 2, 2);

            setAlignments(WorkingImage.EndNull, Stretch.Fill, VerticalAlignment.Bottom, HorizontalAlignment.Center);
            setCollumnsAndLines(WorkingImage.EndNull, gd, 0, 9, 1, 1);

            setAlignments(WorkingImage.Null, Stretch.Fill, VerticalAlignment.Bottom, HorizontalAlignment.Center);
            setCollumnsAndLines(WorkingImage.Null, gd, 0, 9, 1, 2);

            setImagesVisibility(Visibility.Hidden);
            setNullImagesVisibility(Visibility.Hidden);
            }

        /// <summary>
        /// Animates the opacity and sets the margins of the Null Images (images that represent the emptyness of the List).
        /// The margins are positions related to the position of the first element of the List.
        /// </summary>
        /// <param name="thInicioNull">The margin of the inicioNull image</param>
        /// <param name="thFinalNull">The margin of the finalNull image</param>
        /// <param name="thRetNull">The margin of the retNull image</param>
        internal void setNullImagesMarginsAnimated(Thickness thInicioNull, Thickness thFinalNull, Thickness thRetNull)
        {
            inicioNull.Margin = thInicioNull;
            finalNull.Margin = thFinalNull;

            DoubleAnimation dbImageAux = new DoubleAnimation(0, 1, new Duration(TimeSpan.FromSeconds((0.5))));
            finalNull.BeginAnimation(Image.OpacityProperty, dbImageAux);
            inicioNull.BeginAnimation(Image.OpacityProperty, dbImageAux);

            ThicknessAnimation thAnimationNull = new ThicknessAnimation(retNull.Margin, thRetNull, TimeSpan.FromSeconds(0.0));
            retNull.BeginAnimation(Image.MarginProperty, thAnimationNull);
            
        }

        
    }
}
